package com.wanmait.employment.manageController;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.wanmait.employment.entity.NatureWork;
import com.wanmait.employment.mapper.NatureWorkMapper;
import com.wanmait.employment.service.NatureWorkService;
import com.wanmait.employment.util.AjaxResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/manage/naturework")
public class NatureWorkController {
    @Resource
    private NatureWorkMapper natureWorkMapper;
    @Resource
    private NatureWorkService natureWorkService;

    @GetMapping("naturework")
    @ResponseBody
    public AjaxResult natureworkList(String title){
        List<NatureWork> natureWorkList=natureWorkService.findAll(title);
        return AjaxResult.success(natureWorkList);
    }
    @PostMapping("insert")
    public AjaxResult insert(@RequestBody NatureWork natureWork){
        if (natureWork.getId()!=null){
            natureWorkService.update(natureWork);
            return AjaxResult.success("修改成功");

        }else {
            natureWorkService.insert(natureWork);
            return AjaxResult.success("添加成功");
        }
    }
//    @PostMapping("updata")
//    public AjaxResult updata(@RequestBody NatureWork id){
//        natureWorkMapper.updateById(id);
//        return AjaxResult.success("修改成功");
//
//    }
    @GetMapping("delete")
    public AjaxResult delete( Integer id){

        natureWorkService.delete(id);
        return AjaxResult.success("删除成功");

    }






}
